/*
 * Config.h
 *
 *  Created on: 2013. 10. 15.
 *      Author: jjaehuny
 */

#ifndef PROJECTZ_CONFIG_H_
#define PROJECTZ_CONFIG_H_

#include "NUtil/Single.h"
#include <string>

#include <Logger/Static.h>

#include "Enum.h"

namespace ProjectZ {

class Config : public NUtil::Single<Config>
{
public:
	struct Resource_File
	{
		std::string	_myIP;
		int			_identity;
		int			_rankCycle;

		std::string	host;
		std::string user;
		std::string	password;
		std::string	name;

	};

	struct Resource_Database
	{
		bool	_useDebugLog;
		bool	_useStressLog;
		bool	_useProcessLog;
		bool	_useErrorLog;

		// network
		int		_sessionPool;
		int		_lobbyPort;
		int		_port;


		std::string _service_url;

		// middle ware
		std::string _resource_proxy;

		// validator
		std::string _google_validate_url;
		std::string _packageName;
		std::string _publicKey;

		bool	_useViewIntro;
		int 	_channelUniqueIndex;

		bool	_isTest;

		int		_maxChannel;
		int		_maxChannelUser;

		bool	_isBlock;

		std::string 	_strNational;
		National		_enumNational;


		Resource_Database()
		{
			_useDebugLog = true;
			_useStressLog = true;
			_useProcessLog = true;
			_useErrorLog = true;

			_sessionPool = 0;
			_lobbyPort = 0;
			_port = 0;

			_service_url.clear();

			_resource_proxy.clear();

			_google_validate_url.clear();
			_packageName.clear();
			_publicKey.clear();

			_useViewIntro = false;
			_channelUniqueIndex = 0;

			_isTest = false;

			_maxChannel = 0;
			_maxChannelUser = 0;

			_isBlock = false;

			_strNational.clear();
			_enumNational = __NONE__;
		}
	};

public:
	Config();
	virtual ~Config();

	bool	LoadFile();
	bool	LoadDatabase();

	const Resource_File & GetResourceFile() const { return _Resource_File; }
	const Resource_Database & GetResourceDatabase() const { return _Resource_Database; }

	void	AddPacketCount(int count) { _count += count; }

	void	SetUseDebugLog(int use);
	void	SetStressLog(int use);

private:
	std::string getMyIP();

private:
	Resource_File _Resource_File;
	Resource_Database _Resource_Database;

	int _count;

	struct 	Pimple;
	Pimple * 	This;
};

} /* namespace ProjectZ */

#endif /* PROJECTZ_CONFIG_H_ */
